// 查找元素数组中第一个大于等于tartget的下标  
var abb = (list,target) => {
  let start = 0
  let end = list.length - 1
  let count = 0
  if(target >= list[end]) return false
  while(start <= end) {
    count++
    let mid = Math.floor((start+end)/2)
    if(list[mid] === target) {
      return mid
    }else if(list[mid] < target) {
      start = mid + 1
    }else if(list[mid] > target){
      // 注意这里就不要让end = mid - 1
      // 因为mid可能就是刚好第一个大于target的下标
      end = mid
    }
    if(end - start <= 1) {
      console.log(count);
      return end
    }
  }
}
let list = []
for(var i = 1;i<=1000;i++) {
  list.push(i)
}
console.log(abb(list,499.5));